package interfazUsuario.botones;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

import cultivameCore.geometria.Punto;

public class Boton extends BotonAbstract {

	public Boton(Punto p, Image img) {
		super(p, img);
		// TODO Auto-generated constructor stub
	}

	public void drawme(Graphics g) {
		// TODO Auto-generated method stub
		if(isVisible()){
			g.drawImage(getImg(), (int)getPunto().getX(), (int)getPunto().getY(), (Graphics.LEFT|Graphics.TOP));
		}		
	}

	public BotonAbstract isSelected(Punto p) {
		// TODO Auto-generated method stub
		boolean b= p.getX()>this.getPunto().getX() && p.getX()<(this.getPunto().getX()+getImg().getWidth())&&
				   p.getY()>this.getPunto().getY() && p.getY()<(this.getPunto().getY()+getImg().getHeight());
		if(b){
			return this;
		}else{
			return null;
		}
	}

}
